"""
@title(TenX腾晓2024年11月考核答题文件)
@warning(请勿修改参数和返回值)
@warning(请认真填写__init__中的数据)
@author(1323230180)
"""
from typing import List, Tuple


class TenXClass:
    def __init__(self):
        self.name = "李立玮"
        self.id = "3124002012"

    @staticmethod
    def question1(n: int) -> list[str]:
        result = []
        for i in range(1, n + 1):
            a = ''
            while i > 0:
                a = str(i % 4) + a
                i = i // 4
            result.append(a)
        return result

    @staticmethod
    def question2() -> list[tuple[int, int, int]]:
        list1 = []
        for x in range(101):
            for y in range(101):
                for z in range(101):
                    if x + y + z == 100 and 5 * x + 3 * y + z / 3 == 100:
                        tup1 = (x, y, z)
                        list1.append(tup1)
        return list1



    @staticmethod
    def question3(equipment: list[str], prop: list[str], material: list[str], items: list[str]) -> dict[str, list[str]]:
        def classify_item(spoil):
            if spoil in equipment:
                return 'equipment'
            elif spoil in prop:
                return 'prop'
            else:
                return'material'

        dict1 = {'equipment': [], 'prop': [],'material': []}

        for spoil in items:
            category = classify_item(spoil)
            dict1[category].append(spoil)
        return dict1


    @staticmethod
    def question4(item_values: dict[str, int], items: list[str]) -> tuple[list[str], int]:
        sorted_items = sorted(((item, item_values[item]) for item in items), key=lambda x: x[1], reverse=True)
        top_three_items = sorted_items[:3]
        three_obj = [item[0] for item in top_three_items]
        total_value = sum(item[1] for item in top_three_items)
        tua = (three_obj, total_value)
        return tua



    @staticmethod
    def question5(matrix: list[list[int]]) -> list[tuple[int, int]]:
        list1 = []
        for row in range(len(matrix)):
            for col in range(len(matrix[row])):
                element = matrix[row][col]
                if element == 0:
                    tua = (row + 1, col + 1)
                    list1.append(tua)
        return list1

